#include <bits/stdc++.h>
using namespace std;

class Solution {
private:
    void dfs(int k, vector<int>& nums, bool vis[], vector<int>& sub_ans, vector<vector<int>>& ans){
        int size = nums.size();
        if(k == size){
            ans.push_back(sub_ans);
            return;
        }
        for(int i=0; i<size; ++i){
            if(vis[i]) continue;
            vis[i] = true;
            sub_ans.push_back(nums[i]);
            dfs(k+1, nums, vis, sub_ans, ans);
            sub_ans.pop_back();
            vis[i] = false;
        }
    }
public:
    vector<vector<int>> permute(vector<int>& nums) {
        vector<vector<int>> ans;
        int size = nums.size();
        bool *vis = new bool[size]{false};
        vector<int> sub_ans;
        dfs(0, nums, vis, sub_ans, ans);
        delete[] vis;
        return ans;
    }
};

int main(){

}